/*    */ package handling.login.handler;
/*    */ 
/*    */ import client.MapleClient;
/*    */ import java.io.InputStreamReader;
/*    */ import java.io.OutputStreamWriter;
/*    */ import java.io.Reader;
/*    */ import java.io.Writer;
/*    */ import java.net.Socket;
/*    */ import org.apache.logging.log4j.LogManager;
/*    */ import org.apache.logging.log4j.Logger;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CheckLandersMac
/*    */ {
/* 17 */   private static final Logger log = LogManager.getLogger(CheckLandersMac.class);
/*    */ 
/*    */   
/*    */   public static boolean checkMac(MapleClient c) {
/* 21 */     String mac = c.getMac();
/* 22 */     String host = "127.0.0.1";
/* 23 */     int port = 20130;
/* 24 */     StringBuilder sb = new StringBuilder();
/*    */     
/* 26 */     try (Socket client = new Socket(host, port)) {
/*    */       Reader reader;
/* 28 */       try (Writer writer = new OutputStreamWriter(client.getOutputStream())) {
/* 29 */         String wrms = "100|" + mac + "\r\n";
/* 30 */         writer.write(wrms);
/* 31 */         writer.flush();
/*    */         
/* 33 */         reader = new InputStreamReader(client.getInputStream());
/* 34 */         char[] chars = new char[128];
/*    */         
/*    */         int len;
/*    */         
/* 38 */         while ((len = reader.read(chars)) != -1) {
/* 39 */           String temp = new String(chars, 0, len); int index;
/* 40 */           if ((index = temp.indexOf("eof")) != -1) {
/* 41 */             sb.append(temp.substring(0, index));
/*    */             break;
/*    */           } 
/* 44 */           sb.append(temp);
/*    */         } 
/*    */       } 
/* 47 */       reader.close();
/*    */     }
/* 49 */     catch (Exception e) {
/* 50 */       log.error("登录器检测出错", e);
/*    */     } 
/* 52 */     return sb.toString().endsWith("no");
/*    */   }
/*    */   
/*    */   public static boolean sendGateMessage(Object message) {
/* 56 */     String host = "127.0.0.1";
/* 57 */     int port = 20130;
/* 58 */     StringBuilder sb = new StringBuilder();
/*    */ 
/*    */     
/* 61 */     try (Socket client = new Socket(host, port)) {
/*    */       Reader reader;
/*    */       
/* 64 */       try (Writer writer = new OutputStreamWriter(client.getOutputStream())) {
/* 65 */         writer.write(message.toString() + "\r\n");
/* 66 */         writer.flush();
/*    */         
/* 68 */         reader = new InputStreamReader(client.getInputStream());
/* 69 */         char[] chars = new char[128];
/*    */         
/*    */         int len;
/*    */         
/* 73 */         while ((len = reader.read(chars)) != -1) {
/* 74 */           String temp = new String(chars, 0, len); int index;
/* 75 */           if ((index = temp.indexOf("eof")) != -1) {
/* 76 */             sb.append(temp.substring(0, index));
/*    */             break;
/*    */           } 
/* 79 */           sb.append(temp);
/*    */         } 
/*    */       } 
/* 82 */       reader.close();
/*    */     }
/* 84 */     catch (Exception e) {
/* 85 */       log.error("发送消息出错", e);
/*    */     } 
/* 87 */     return sb.toString().endsWith("no");
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\handling\login\handler\CheckLandersMac.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */